import {createStore} from "vuex";

const store = createStore({
    state:{
        todoList:
        [
            {isChecked:false,id:1,task: '第一个任务'},
            {isChecked:true,id:2,task: '第二个任务'},
            {isChecked:true,id:3,task: '第三个任务'}
        ]
    }
    ,
    mutations:{
        add(state,payload){
            state.todoList.unshift({isChecked: false,id:state.todoList.length,task: payload})
        },
        clear(state){
            state.todoList = [];
        }
    },
    actions:{

    },
    getters:{
        complete(state){
            return state.todoList.filter(item => item.isChecked)
        },
        incomplete(state){
            return state.todoList.filter(item => !item.isChecked)
        },
    },

    //引入模块
    modules:{
    }
})

export default store